<template>
  <div>
    <div class="nav">
      <div class="nav-header">
        <div class="nav-l">
          <h1>音乐播放器</h1>
          <li>发现音乐</li>
          <li>关注</li>
          <li>商城</li>
          <li>音乐人</li>
        </div>
        <div class="nav-r">
          <input type="text" placeholder="搜索" v-model="searchCon" />
          <a @click="login()" class="login">{{ username }}</a>
        </div>
      </div>
    </div>

    <banner />
    <Hot/>
  </div>
</template>

<script>
import banner from "@/view/banner";
import Hot from "./view/hot.vue";
export default {
  name: "Home",
  data() {
    return {
      username: "登录",
      searchCon: "",
    };
  },
  components: {
    banner: banner,
    Hot:Hot
},
  mounted() {
    // console.log(location.nickname);
    if(location.nickname == undefined){
      this.username = '登录'
      // this.$router.push('/login')
    }else{
      this.username = location.nickname;
      // this.$router.push("/status")
    }
  },

  methods: {
    login(){
      if(location.nickname == undefined){
      // this.username = '登录'
      this.$router.push('/login')
    }else{
      // this.username = this.$route.params.nickname;
      this.$router.push("/status")
    }
    }
  },
};
</script>

<style lang="less" scoped>
* {
  margin: 0;
  padding: 0;
}
.nav {
  width: 100%;
  height: 70px;
  overflow: hidden;
  & > .nav-header {
    width: 1450px;
    height: 100%;
    background: paleturquoise;
    line-height: 70px;
    margin: 0 auto;

    & > .nav-l {
      float: left;
      width: 850px;
      cursor: default;
      & > h1 {
        width: 250px;
        height: 100%;
        line-height: 70px;
        display: inline-block;
        font-size: xx-large;
        overflow: hidden;
        padding-left: 40px;
      }
      & > li {
        list-style: none;
        width: 100px;
        height: 100%;
        display: inline-block;
        font-size: large;
        overflow: hidden;
        text-align: center;
        cursor: default;
        color: #666;
        &:hover {
          background-color: aquamarine;
        }
      }
    }
    & > .nav-r {
      width: 300px;
      float: right;
      margin-right: 40px;
      cursor: default;
      & > a {
        line-height: 70px;
        color: black;
        text-decoration: none;
        cursor: default;
        &:hover {
          color: gray;
        }
      }
      & > input {
        cursor: default;
        width: 200px;
        height: 30px;
        margin-right: 30px;
        border-radius: 25px;
        font-size: larger;
        padding-left: 20px;
      }
    }
  }
}
</style>
